if [ -f deploy/scripts/jquery.js ];
then
   echo "Removing Jquery";
   rm deploy/scripts/jquery.js;
fi
cd deploy/scripts
echo "appending all files packed.js";
touch packed.tmp
cat jquery.accordion.js >> packed.tmp
cat jquery.template.js >> packed.tmp
cat pngcorners.js >> packed.tmp
cat default.js >> packed.tmp
cat speech.js >> packed.tmp
rm *.js
cd ../../

echo "Compressing JS to packed.js";

java -jar yuicompressor.jar -o deploy/scripts/packed.js --type js deploy/scripts/packed.tmp
rm deploy/scripts/packed.tmp

perl -pi.bak -e 's/<!-- JsPackStart -->/<!-- JsPackStart/g' deploy/index.html
perl -pi.bak -e 's/<!-- JsPackEnd -->/JsPackEnd -->/g' deploy/index.html
perl -pi.bak -e 's/<!--script type="text\/javascript" src="scripts\/packed.js"><\/script-->/<script type="text\/javascript" src="scripts\/packed.js"><\/script>/g' deploy/index.html
rm deploy/index.html.bak